<%-- 
    Document   : login
    Created on : Feb 9, 2009, 4:21:30 AM
    Author     : salim


--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%@page import="isae.lib.*"%>
<%@page import="pack1.*"%>
<%@ page import="java.util.List" %>
<%@ page import="datapackage.*" %>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Login ...Horaire ISAE Cnam Liban</title>
        <jsp:useBean id="param" class="datapackage.AnCeBean" scope="session" />
        <jsp:useBean id="dl" class="datapackage.DivertList" scope="session" />
        <jsp:setProperty  name="param" property="*"/>
        <jsp:useBean id="il" class="isae.lib.InitialLists" scope="session"/>
        <jsp:useBean id="gm" class="pack1.GenericMethods" scope="application"/>
        <jsp:useBean  id="iq" class="isae.lib.InitialQuerys" scope="application"/>

        <link rel="stylesheet" type="text/css" href="background.css" />
        <%--  <link rel="stylesheet" type="text/css" href="http://10.130.0.12/themes/cofares.css" />  --%>

        <script type="text/javascript">
            document.onkeypress = autoSearch;
            function autoSearch() {
                if ((event.which && event.which == 13) || (event.keyCode && event.keyCode== 13))
                {
                    document.forms[0].submit();
                }
                return true;
            }
        </script>

    </head>
    <body>
        <div id="index-content">
            <form action="login.jsp" method="post">
                <H2 ALIGN="center"> Bienvenue au Système d'Information de l'ISAE 
                    <br>
                    <br>
                Gestion-Horaire</H2>
                <table align="center">
                    <tr>
                        <td>Nom utilisateur:</td>
                        <td><input type="Text" name="username"></td>
                    </tr>
                    <tr>
                        <td>Mot de passe:</td>
                        <td><input type="password" name="password"></td>
                    </tr>

                </table>
                <br><p align="center"> <input type="submit" value="Valider"></p>
            </form>
        </div>
       <%-- <div id="index-pub">

            <form action="login.jsp" method="post" >
                
               
                <table align="center" border="2" width="400px">
                    <h4> <tr><td height="70px"> Nom utilisateur:</td><td><input name="username"  type="text" size="15"></td></tr></h4>
                    <h4><tr><td height="70px"> Mot de passe:</td><td><input name="password" type="password" size="15"></td></tr></h4>
                </table>
                <center> <input type="button" onclick="submit()"  value="Valider"/></center>
            </form>

        </div>
       --%>
        <%
        if (param.getUsername() != null && param.getPassword() != null) {
            List<isae.lib.User> l = il.avoirUtilisateur(param.getUsername(), param.getPassword());
            if (l.isEmpty()) {
                out.println("Votre nom et/ou votre mot de passe sont incorrects.");
            } else {
                for (isae.lib.User u : l) {

                    if (u.getFonction().equalsIgnoreCase("chef")) {
                        param.setNoChef(u.getNo());//if user has logged in
                        //InitialQuerys iq=new InitialQuerys();
                        String pn = iq.avoirChef(u.getNo());
                        param.setPrenomnomchef(pn);%>
        <jsp:forward page="cleanpage.jsp"></jsp:forward>
<%       } else if (u.getFonction().equalsIgnoreCase("employe")&& (dl.AleDroit(u.getNo(),"horaire"))) {

                        param.setNoEmp(u.getNo());
                        String pnEmp = iq.avoirEmploye(u.getNo());
                        Employe emp=gm.AvoirEmploye(u.getNo());
                        param.setCentreEmp(emp.getIdCentre());
                        param.setPrenomnomEmp(pnEmp);%>
        <jsp:forward page="cleanpage.jsp"></jsp:forward>
        <%
                    }//fi de if employe
                }//fin du for user
            }//end else
        }//end if not null %>
    </body>
</html>
